import React, { useEffect } from "react";
import { connect } from 'react-redux'
import { fetchUser } from "../store/actions/user.action";

function loadData(store){
  return store.dispatch(fetchUser())
}

function List({user,dispatch}){
  useEffect(()=>{
    dispatch(fetchUser())
  },[])
  return <div>List page works
    <ul>{user.map(item=> <li key={item.id}>{item.name}</li>)}</ul>
  </div>
}

const mapStateToporps = state => ({
  user: state.user
})

export default {
  component: connect(mapStateToporps)(List),
  loadData
} 